﻿#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include "QueueLinkStore.h"

struct PersonQueue
{
	struct QueueNode node;
	char name[64];
	int age;
};

void testQueueLink()
{
	//1.初始化队列；
	LinkQueue queue = Init_LinkQueue();

	//2.创建数据；
	struct PersonQueue p1 = { NULL,"aaa",10 };
	struct PersonQueue p2 = { NULL,"bbb",20 };
	struct PersonQueue p3 = { NULL,"ccc",30 };
	struct PersonQueue p4 = { NULL,"ddd",40 };
	struct PersonQueue p5 = { NULL,"eee",50 };

	//3.插入队列；
	Push_LinkQueue(queue, &p1);
	Push_LinkQueue(queue, &p2);
	Push_LinkQueue(queue, &p3);
	Push_LinkQueue(queue, &p4);
	Push_LinkQueue(queue, &p5);

	struct PersonQueue* pBack = (struct PersonQueue*)Back_LinkQueue(queue);
	printf("21.输出队尾元素pBack的Name：%s  Age：%d\n", pBack->name, pBack->age);//pBack的Name：eee  Age：50

	while (Size_LinkQueue(queue) > 0)
	{
		//16.获得队头元素；
		struct PersonQueue* person = (struct PersonQueue*)Front_LinkQueue(queue);
		//17.打印输出队头元素；
		printf("18.输出队头元素person的Name：%s  Age：%d\n", person->name, person->age);//10,20,30,40,50	
		//19.弹出队头元素；
		Pop_LinkQueue(queue);
	}

	//20.销毁队列；
	Destroy_LinkQueue(queue);

}

//main227：队列的链式存储
int main227()
{
	testQueueLink();

	system("pause");
	return EXIT_SUCCESS;
}